package com.aha.secondchapter.first;

/**
 * 自定义队列
 * Created by wangxin on 2015/10/28.
 */
public class MyQueue {
    private int head;
    private int tail;
    private int[] data;
    public MyQueue(){

    }
    public MyQueue(int[] arr){
        int[] d = new int[102];
        System.arraycopy(arr,0,d,0,arr.length);
        this.data = d;
        this.head = 0;
        this.tail = arr.length;
    }
    /**
     * 出队
     */
    public int out(){
        int headData = data[head];
        data[head] = 0;
        head++;
        return headData;
    }

    /**
     * 入队
     * @param i
     */
    public void in(int i){
        data[tail] = i;
        tail++;
    }
    public boolean isEmpty(){
        return this.head == this.tail;
    }
    public int getHead() {
        return head;
    }

    public void setHead(int head) {
        this.head = head;
    }

    public int getTail() {
        return tail;
    }

    public void setTail(int tail) {
        this.tail = tail;
    }

    public int[] getData() {
        return data;
    }

    public void setData(int[] data) {
        this.data = data;
    }
}
